package com.besttone.kafka.web;

import java.util.Random;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.besttone.kafka.support.SimpleResponse;

@RestController
public class ProducerController {
	Logger logger=LoggerFactory.getLogger(getClass());
	@Autowired
	KafkaTemplate<String,String> kafkaTemplate;
		
	@GetMapping("/test/send")
	public SimpleResponse send() {
		logger.info("{}"+System.currentTimeMillis());

		kafkaTemplate.send("test", "hello"+new Random().nextInt());
		return new SimpleResponse("发送消息成功");
	}
}
